package com.stylefeng.guns;

import com.stylefeng.guns.config.ScriptRunnerExecSql;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * Created by jondai on 2017/12/20.
 */
@Component
public class ApplicationStartup implements ApplicationListener<ContextRefreshedEvent> {

    @Autowired
    private ScriptRunnerExecSql scriptRunnerExecSql;

    public void onApplicationEvent(ContextRefreshedEvent event)
    {
        try {
            scriptRunnerExecSql.init();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
